package com.neu.his.utils;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import lombok.Data;

import java.util.List;

/**
 * @类 名： PageList <br/>
 * @描 述： <br/>
 * @日 期： 2020/7/13 11:01<br/>
 * @作 者： 侯建军<br/>
 * @版 本： 1.0.0
 * @since JDK 1.8
 */
@Data
public class PageList<T> {
    private Long pages;
    private Long total;
    private Long pageSize;
    private Long current;
    private List<T> records;

    public PageList() {

    }

    public PageList(List<T> list, Long current, Long pageSize) {
        int total = list.size();
        int i = (current.intValue() - 1) * pageSize.intValue();
        int j = i + pageSize.intValue();
        records = list.subList(i < total ? i : total, j < total ? j : total);
        this.setCurrent(current);
        this.setPageSize(pageSize);
        this.setTotal(new Long(total));
        this.setPages(total % pageSize == 0 ? total / pageSize : total / pageSize + 1);
    }
}
